﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.ObjectModel;
using WpfEfDAL;

namespace WpfEfDataEntry
{

    public class CustomerCollection : ObservableCollection<Customer>
    {

        private OMSEntities _context;
        public OMSEntities Context
        {
            get { return _context; }
        }

        public CustomerCollection(IEnumerable<Customer> customers, OMSEntities context):base(customers)            
        {
            _context = context;
        }

        protected override void InsertItem(int index, WpfEfDAL.Customer item)
        {
            this.Context.AddToCustomers(item);
            base.InsertItem(index, item);
        }

        protected override void RemoveItem(int index)
        {
            this.Context.DeleteObject(this[index]);
            base.RemoveItem(index);
        }

    }
   
}
